﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Tour.BLL;
using Tour.DAL;

public partial class Modules_Tour_TourDetailAE : VST.Controls.BaseLCGPage
{
    public int? TourId { get; set; }
    public int? TourDetailId { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        TourId = CommonHelper.QueryStringInt("TourId", null);
        TourDetailId = CommonHelper.QueryStringInt("TourDetailId", null);
        if (!TourId.HasValue)
            Response.Redirect("TourList.aspx");
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    void LoadData()
    {
        if (TourDetailId.HasValue)
        {
            TblTourDetailEntity item = TblTourDetailManager.CreateInstant().SelectOne(TourDetailId.Value);
            txtName.Text = item.Name;
            radEditorContent.Content = item.Description;
        }
    }
    TblTourDetailEntity GetTblTourDetail()
    {
        TblTourDetailEntity item = new TblTourDetailEntity();
        if (TourDetailId.HasValue)
        {
            item = TblTourDetailManager.CreateInstant().SelectOne(TourDetailId.Value);
        }
        else
        {
            item.Id = 0;
           
            item.TourId = TourId.Value;
            item.DisplayOrder = 50;
            item.CreatedDate = DateTime.Now;
        }
        item.Name = txtName.Text;
        item.Description = radEditorContent.Content;
        return item;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        TblTourDetailManager.CreateInstant().InsertUpdate(GetTblTourDetail());
        Response.Redirect("TourDetailList.aspx?TourId=" + TourId);
    }
}